<template>
<button @click="show = !show">显示/隐藏</button>
<transition name="slide">
    <div v-if="show" class="dv">滑动进入效果</div>
</transition>
</template>
<script setup>
import { ref } from 'vue';

let show =ref(false);
</script>
<style>
.dv{
    margin-top: 20px;
    padding: 30px;
    width: 200px;
    background-color: burlywood;
    color: cadetblue;
}
.slide-enter-active{
    transition: all 2s ease-out;
}
.slide-leave-active{
    transition: all 2s ease-in;
}
.slide-enter-from{
    transform: translateX(-500px);
    opacity: 0;
}
.slide-leave-to{
    transform: translateX(-500px);
    opacity: 0;
}
</style>